<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</meta>
<title>F.merge</title>
<link type="text/css" rel="stylesheet" href="../css/admin.css" />
<link type="text/css" rel="stylesheet" href="../css/item_show.css" />
<script type="text/javascript" src="../../1st.js"></script>
<script type="text/javascript" src="../../1st.highlight.js"></script>
</head>
<body id="split">
<div id="content">
	<div rel="F.param">
		<h2><span>返回值:</span>F.merge</h2>
					<h3>概述 : 合并对象</h3>
						
			<div class="desc">
				<div class="longdesc"><pre>循环目标对象，合并到源对象

$type=1 覆盖 key不增加
$type=2 添加 key增加
$type=0 覆盖和添加 key可能增加(默认)</pre></div>
			</div>
							<h3>语法1：F.merge(source, target, $type)</h3>
							<div>描述：合并key</div>
						<table class="args">
				<!--caption>参数列表：(3)</caption-->
				<tr><th>参数名称</th><th>类型</th><th>描述</th></tr>
									<tr><td><strong>source</strong></td><td>Object</td><td>源对象</td></tr>
									<tr><td><strong>target</strong></td><td>Object</td><td>目标对象</td></tr>
									<tr><td><strong>$type</strong></td><td>Number</td><td>合并方式：0全部合并(默认)、1只合并源对象存在的key、2只合并源对象不存在的key</td></tr>
								<tr><td colspan="3">&nbsp;</td></tr>
				<tr><td>返回值</td><td>Object</td><td>返回合并后的源对象</td></tr>
			</table>
					<h3>语法2：F.merge(source, key, val)</h3>
							<div>描述：添加key</div>
						<table class="args">
				<!--caption>参数列表：(3)</caption-->
				<tr><th>参数名称</th><th>类型</th><th>描述</th></tr>
									<tr><td><strong>source</strong></td><td>Object</td><td>源对象</td></tr>
									<tr><td><strong>key</strong></td><td>String</td><td>健名</td></tr>
									<tr><td><strong>val</strong></td><td>Variable</td><td>键值</td></tr>
								<tr><td colspan="3">&nbsp;</td></tr>
				<tr><td>返回值</td><td>Object</td><td>返回添加后的源对象</td></tr>
			</table>
				<div class="example">
			<h3>示例 : </h3>
						
									
				<h5 xmlns="">JS代码:</h5>
				<pre xmlns=""><code id="jsbox"></code></pre>
										
				<h5 xmlns="">结果:</h5>
				<pre xmlns=""><code id="resultbox"></code><code></code></pre>
					</div>
		<div style="text-align:right">
			
					
				<button onclick="window.open('../codepages/120.html');">运行代码</button>
						
		</div><br/>	
		<div>
			<h3>同类参考 :</h3>
			<div>
							<span><a href='113.html'>F.clone</a></span>&#12288;|&#12288;							<span><a href='101.html'>F.cut</a></span>&#12288;|&#12288;							<span><a href='176.html'>F.flip</a></span>&#12288;|&#12288;							<span><a href='49.html'>F.each</a></span>						</div>
		</div>
	</div>
</div><br />

<textarea id="css" style="display:none;"></textarea>
<textarea id="html" style="display:none;"></textarea>
<textarea id="js" style="display:none;">var o1 = {a:1,b:2};
var o2 = {c:3,d:4};
F.merge(o1,o2);
F.alert(o1);

F.merge(o1,"e",5);
F.alert(o1);</textarea>
<textarea id="result" style="display:none;">{"a":1,"b":2,"c":3,"d":4}
{"a":1,"b":2,"c":3,"d":4,"e":5}</textarea>


<script type="text/javascript">
var css = F('css').val();
var html = F('html').val();		
var js = F('js').val();
var result = F('result').val();
css && F('cssbox').highlight(css, "css");
html && F('htmlbox').highlight(html, "html");
js && F('jsbox').highlight(js, "js");
result && F('resultbox').highlight(result,"js");
</script>

</body>
</html>